package great.project.oauth2.service;

import great.project.oauth2.pojo.UserDO;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *
 * @author v_zhangshun01
 * @date 2022/2/7 4:43 PM
 */
@Service
public class UserServiceImpl implements UserDetailsService {

    @Resource
    private PasswordEncoder passwordEncoder;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        String pwd = passwordEncoder.encode("123456");
        return new UserDO(username, pwd , AuthorityUtils
                .commaSeparatedStringToAuthorityList("admin")) ;
    }

}
